<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>Admin Panel</title>
    </h:head>
    <h:body>
        <ui:composition template="templates/main-template.xhtml">
            <ui:define name="title">Speed Dial - Admin</ui:define>
            <ui:define name="content">
                <h1>Admin Panel</h1>
                <h:panelGroup class="align-center" >
                <h:dataTable id ="userstable" value="#{adminManagedBean.userList}" 
                             var="user" 
                             headerClass="admin-table-head" columnClasses="admin-table-column"
                             class="admin-table" rowClasses="admin-table-row1,admin-table-row2">
                        <h:column>
                            <f:facet name="header">
                                Felhasználóinév
                            </f:facet>
                            <h:outputText value="#{user.username}" />
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                Emailcím
                            </f:facet>
                            <h:outputText value="#{user.email}" />
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                Szerep
                            </f:facet>
                            <h:outputText value="#{user.role_a_JAAS_miatt}" />
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                Bejelentkezve
                            </f:facet>
                            <h:outputText value="IGEN" rendered="#{user.logedIn}" style="color: green;" />
                            <h:outputText value="NEM" rendered="#{not user.logedIn}" style="color: red;"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                Törlés
                            </f:facet>
                            <h:form>
                            <h:commandButton value="Töröl" action="#{adminManagedBean.removeUser}">
                                <f:param name="username" value="#{user.username}" />
                            </h:commandButton>
                            </h:form>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                Új szerep
                            </f:facet>
                            <h:form rendered="#{user.role_a_JAAS_miatt eq 'USER'}">
                            <h:commandButton value="ADMIN" action="#{adminManagedBean.toAdmin}">
                                <f:param name="username" value="#{user.username}" />
                            </h:commandButton>
                            </h:form>
                            <h:form rendered="#{user.role_a_JAAS_miatt eq 'ADMIN'}">
                            <h:commandButton value="USER" action="#{adminManagedBean.toUser}">
                                <f:param name="username" value="#{user.username}" />
                            </h:commandButton>
                            </h:form>
                        </h:column>
                    </h:dataTable>
                </h:panelGroup>
            </ui:define>
        </ui:composition>
    </h:body>
</html>

